﻿//
// Created by Administrator on 2020/9/20.
//
#include <iostream>
#include <string>
#include <memory>

class Report {
private:
    std::string *str;
public:
    Report(const std::string &str) {
        this->str = new std::string(str);
    }

    ~Report() {
        using namespace std;
        cout << "release: " << *str << endl;
        delete this->str;
    }

    void content() {
        using namespace std;
        cout << *str << endl;
    }
};

int main() {

    {
        std::auto_ptr<Report> autoPtr(new Report("AutoPtr Test"));
        autoPtr->content();
    }


    {
        std::shared_ptr<Report> sharedPtr(new Report("shared_ptr Test"));
        sharedPtr->content();
    }


    {
        std::unique_ptr<Report> uniquePtr(new Report("unique_ptr Test"));
        uniquePtr->content();
    }


    {
        using namespace std;
        cout << "*************************************************************" << endl;
        Report reportArr[] = {
                Report("R1"),
                Report("R2")
        };
    }
    {
        using namespace std;
        cout << "*************************************************************" << endl;
        std::shared_ptr<Report> reportArr2[]{
                std::shared_ptr<Report>(new Report("R1")),
                std::shared_ptr<Report>(new Report("R2")),

        };
    }

}